package org.zhadoop.streaming.application;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zhadoop.streaming.config.StreamingConfig;
import org.zhadoop.streaming.event.EventTypeMng;
import org.zhadoop.streaming.exception.ErrorCode;
import org.zhadoop.streaming.exception.StreamingException;

import com.google.common.base.Strings;

/**
 * 应用管理
 * @author zwd
 *
 */
public class Application {
	private static final Logger LOG = LoggerFactory.getLogger(Application.class);
	
	/**
	 * 应用程序名称
	 */
	private String appName;
	
	 /**
     * 所有Schema集合
     */
    private EventTypeMng streamSchema;
    
    /**
     * 算子集合
     */
    private OperatorMng operatorManager;
    
    /**
     * 系统级别的配置属性
     */
    private StreamingConfig conf;
    
    public Application(String appName,StreamingConfig config) throws StreamingException{
    	if(Strings.isNullOrEmpty(appName)){
    		LOG.error("Application name is null.");
            throw new StreamingException(ErrorCode.UNKNOWN_SERVER_COMMON_ERROR);
    	}
    	
    	if(config == null){
    		LOG.error("Configuration is null when build application topology.");
            throw new StreamingException(ErrorCode.UNKNOWN_SERVER_COMMON_ERROR);
    	}
    	
    	this.conf = config;
        this.appName = appName;
        this.streamSchema = new EventTypeMng();
        this.operatorManager = new OperatorMng();
    }
    
    
}
